

package com.example.administrator.caigou51.recyclerCard.cardView;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.example.administrator.caigou51.EventBusClass.RefreshOrderListActivity;
import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.activity.CheckOrderActivity;
import com.example.administrator.caigou51.activity.GBaseActivity;
import com.example.administrator.caigou51.activity.MainActivity;
import com.example.administrator.caigou51.activity.OrderDetailActivity;
import com.example.administrator.caigou51.activity.OrderListActivity;
import com.example.administrator.caigou51.activity.PayMoneyActivity;
import com.example.administrator.caigou51.activity.WebHtmlActivity;
import com.example.administrator.caigou51.bean.OrderInfoBean;
import com.example.administrator.caigou51.bean.PayBean;
import com.example.administrator.caigou51.bean.UserBean;
import com.example.administrator.caigou51.global.App;
import com.example.administrator.caigou51.global.Constant;
import com.example.administrator.caigou51.recyclerCard.basic.CardItemView;
import com.example.administrator.caigou51.recyclerCard.basic.MaterialListAdapter;
import com.example.administrator.caigou51.recyclerCard.card.OrderListItemCard;
import com.example.administrator.caigou51.recyclerCard.card.ShopCarCard;
import com.example.administrator.caigou51.request.BaseResponse;
import com.example.administrator.caigou51.request.ICallBackForRequestServer;
import com.example.administrator.caigou51.request.RequestServerManager;
import com.example.administrator.caigou51.util.ImageUtil;
import com.example.administrator.caigou51.util.ToastUtil;
import com.example.administrator.caigou51.widget.dialog.SweetDialogManager;

import java.io.Serializable;

import cn.pedant.SweetAlert.SweetAlertDialog;
import de.greenrobot.event.EventBus;


public class OrderListItemCardView extends CardItemView<OrderListItemCard> implements View.OnClickListener{
 	private Context mContext;
    private TextView textViewWaitStatus;
    private ImageView imageViewDel;
    private LinearLayout linearLayoutFiveGoods,linearLayoutOneGoods,linearLayoutMoreGoods;
    private ImageView imageViewOneGoods;
    private TextView imageViewOneGoodsName,textViewOrderTime;
    private ImageView imageView_more1;
    private ImageView imageView_more2;
    private ImageView imageView_more3;
    private ImageView imageView_more4;
    private ImageView imageView_more5;
    private TextView textViewMoney;
    private TextView textViewIconMoney;
    private TextView textViewCount;
    private TextView textViewPayMoneyRed;
    private TextView textViewBuyAgainGrey;
    private ImageView imageViewFinish;
    private OrderListItemCard orderListItemCard;
    public OrderListItemCardView(Context context) {
        super(context);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public OrderListItemCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public OrderListItemCardView(Context context,
                                 AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext=context;
        // TODO Auto-generated constructor stub
    }
    @Override
    public void build(OrderListItemCard card) {
        // TODO Auto-generated method stub
        super.build(card);
        this.orderListItemCard=card;
        textViewWaitStatus = (TextView) findViewById(R.id.textViewWaitStatus);
        textViewOrderTime= (TextView) findViewById(R.id.textViewOrderTime);
        imageViewDel = (ImageView) findViewById(R.id.imageViewDel);
        linearLayoutFiveGoods = (LinearLayout) findViewById(R.id.linearLayoutFiveGoods);
        linearLayoutOneGoods = (LinearLayout) findViewById(R.id.linearLayoutOneGoods);
        linearLayoutMoreGoods = (LinearLayout) findViewById(R.id.linearLayoutMoreGoods);
        imageViewOneGoods = (ImageView) findViewById(R.id.imageViewOneGoods);
        imageViewOneGoodsName = (TextView) findViewById(R.id.imageViewOneGoodsName);
        imageView_more1 = (ImageView) findViewById(R.id.imageView_more1);
        imageView_more2 = (ImageView) findViewById(R.id.imageView_more2);
        imageView_more3 = (ImageView) findViewById(R.id.imageView_more3);
        imageView_more4 = (ImageView) findViewById(R.id.imageView_more4);
        imageView_more5 = (ImageView) findViewById(R.id.imageView_more5);
        textViewMoney = (TextView) findViewById(R.id.textViewMoney);
        textViewIconMoney = (TextView) findViewById(R.id.textViewIconMoney);
        textViewCount = (TextView) findViewById(R.id.textViewCount);
        textViewPayMoneyRed = (TextView) findViewById(R.id.textViewPayMoneyRed);
        textViewBuyAgainGrey = (TextView) findViewById(R.id.textViewBuyAgainGrey);
        imageViewFinish = (ImageView) findViewById(R.id.imageViewFinish);



        textViewOrderTime.setText("下单时间:"+card.getOrderInfoBean().getUpdatetime());
        textViewCount.setText("共"+card.getOrderInfoBean().getGoods().size()+"件商品 实际付款：");
        textViewMoney.setText(card.getOrderInfoBean().getPay_amount()+"");



                if (card.getOrderInfoBean().getStatus().equals(OrderListActivity.DFK+""))
                {
                    showViewDfk(card);
                }else if (card.getOrderInfoBean().getStatus().equals(OrderListActivity.DFH+""))
                {
                    showViewDfh(card);
                }else if (card.getOrderInfoBean().getStatus().equals(OrderListActivity.DSH+""))
                {
                    showViewDsh(card);
                }else if (card.getOrderInfoBean().getStatus().equals(OrderListActivity.JYWG+""))
                {
                    showViewYwc(card);
                }else if (card.getOrderInfoBean().getStatus().equals(OrderListActivity.YQX_1+"") || card.getOrderInfoBean().getStatus().equals(OrderListActivity.YQX_2+""))
                {
                    showViewYqx(card);
                }else if (card.getOrderInfoBean().getStatus().equals(OrderListActivity.HDFK+"") )
                {
                    showViewHDFK(card);
                }





  setOnClickListener(this);
    }

    private void showViewMoreGoods(OrderListItemCard card) {
        if (card.getOrderInfoBean().getGoods().size()>1)
        {
            linearLayoutMoreGoods.setVisibility(View.VISIBLE);
            linearLayoutOneGoods.setVisibility(View.GONE);

            if (card.getOrderInfoBean().getGoods().size()>4)
            {
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(0).getThumb(),imageView_more1, ImageUtil.OptionsActivity());
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(1).getThumb(),imageView_more2, ImageUtil.OptionsActivity());
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(2).getThumb(),imageView_more3, ImageUtil.OptionsActivity());
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(3).getThumb(),imageView_more4, ImageUtil.OptionsActivity());
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(4).getThumb(),imageView_more5, ImageUtil.OptionsActivity());
                imageView_more1.setVisibility(View.VISIBLE);
                imageView_more2.setVisibility(View.VISIBLE);
                imageView_more3.setVisibility(View.VISIBLE);
                imageView_more4.setVisibility(View.VISIBLE);
                imageView_more5.setVisibility(View.VISIBLE);
            }else if (card.getOrderInfoBean().getGoods().size()>3)
            {
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(0).getThumb(),imageView_more1, ImageUtil.OptionsActivity());
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(1).getThumb(),imageView_more2, ImageUtil.OptionsActivity());
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(2).getThumb(),imageView_more3, ImageUtil.OptionsActivity());
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(3).getThumb(),imageView_more4, ImageUtil.OptionsActivity());
                imageView_more1.setVisibility(View.VISIBLE);
                imageView_more2.setVisibility(View.VISIBLE);
                imageView_more3.setVisibility(View.VISIBLE);
                imageView_more4.setVisibility(View.VISIBLE);
                imageView_more5.setVisibility(View.INVISIBLE);
            }else if (card.getOrderInfoBean().getGoods().size()>2)
            {
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(0).getThumb(),imageView_more1, ImageUtil.OptionsActivity());
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(1).getThumb(),imageView_more2, ImageUtil.OptionsActivity());
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(2).getThumb(),imageView_more3, ImageUtil.OptionsActivity());
                imageView_more1.setVisibility(View.VISIBLE);
                imageView_more2.setVisibility(View.VISIBLE);
                imageView_more3.setVisibility(View.VISIBLE);
                imageView_more4.setVisibility(View.INVISIBLE);
                imageView_more5.setVisibility(View.INVISIBLE);
            }else if (card.getOrderInfoBean().getGoods().size()>1)
            {
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(0).getThumb(),imageView_more1, ImageUtil.OptionsActivity());
                App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(1).getThumb(),imageView_more2, ImageUtil.OptionsActivity());
                imageView_more1.setVisibility(View.VISIBLE);
                imageView_more2.setVisibility(View.VISIBLE);
                imageView_more3.setVisibility(View.INVISIBLE);
                imageView_more4.setVisibility(View.INVISIBLE);
                imageView_more5.setVisibility(View.INVISIBLE);
            }


        }else
        {
            linearLayoutMoreGoods.setVisibility(View.GONE);
            linearLayoutOneGoods.setVisibility(View.VISIBLE);

            App.displayImageHttpOrFile(card.getOrderInfoBean().getGoods().get(0).getThumb(),imageViewOneGoods, ImageUtil.OptionsActivity());
            imageViewOneGoodsName.setText(card.getOrderInfoBean().getGoods().get(0).getTitle()+"\n"+card.getOrderInfoBean().getGoods().get(0).getProduct_spec());

        }

    }

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    private void showViewDfk(final OrderListItemCard card) {
        imageViewFinish.setVisibility(View.GONE);
        imageViewDel.setVisibility(View.GONE);
        textViewWaitStatus.setVisibility(View.VISIBLE);
        textViewWaitStatus.setText("等待付款");
        textViewWaitStatus.setTextColor(getResources().getColor(R.color.red));

        textViewPayMoneyRed.setVisibility(View.VISIBLE);
        textViewPayMoneyRed.setText("去支付");

        textViewPayMoneyRed.setBackgroundResource(R.drawable.shape_radian_red);
        textViewBuyAgainGrey.setVisibility(View.VISIBLE);
        textViewBuyAgainGrey.setText("取消订单");
        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        layoutParams.addRule(RelativeLayout.LEFT_OF,R.id.textViewPayMoneyRed);
        textViewBuyAgainGrey.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                SweetDialogManager.getInstance().showDialogByWarmTitleText((GBaseActivity) mContext, "确认要取消订单吗?", "", false, false, new SweetAlertDialog.OnSweetClickListener() {
                    @Override
                    public void onClick(SweetAlertDialog sweetAlertDialog) {
                        sweetAlertDialog.dismiss();

                    }
                }, new SweetAlertDialog.OnSweetClickListener() {
                    @Override
                    public void onClick(SweetAlertDialog sweetAlertDialog) {
                        sweetAlertDialog.dismiss();
                        taskCancelOrder(false,(GBaseActivity) mContext,card.getOrderInfoBean().getOrder_id());
                    }
                });

            }
        });
        textViewPayMoneyRed.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                PayBean payBean = new PayBean();
                payBean.setOrder_id(card.getOrderInfoBean().getOrder_id());
                payBean.setPay_amount(card.getOrderInfoBean().getPay_amount()+"");
                Intent intetn =new Intent(mContext,PayMoneyActivity.class);
                intetn.putExtra(PayMoneyActivity.TagPayBean, (Serializable) payBean);
                mContext.startActivity(intetn);
            }
        });
/*        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.LEFT_OF);
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);*/
        showViewMoreGoods(card);
    }
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    private void showViewHDFK(final OrderListItemCard card) {
        imageViewFinish.setVisibility(View.GONE);
        imageViewDel.setVisibility(View.GONE);
        textViewWaitStatus.setVisibility(View.VISIBLE);
        textViewWaitStatus.setText("正在出货");
        textViewWaitStatus.setTextColor(getResources().getColor(R.color.red));

        textViewPayMoneyRed.setVisibility(View.GONE);
        textViewPayMoneyRed.setBackgroundResource(R.drawable.shape_radian_green);
        textViewPayMoneyRed.setText("查看物流");

        textViewBuyAgainGrey.setVisibility(View.VISIBLE);
        textViewBuyAgainGrey.setText("取消订单");
        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.LEFT_OF);
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        showViewMoreGoods(card);
        textViewBuyAgainGrey.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

                SweetDialogManager.getInstance().showDialogByWarmTitleText((GBaseActivity) mContext, "确认要取消订单吗?", "", false, false, new SweetAlertDialog.OnSweetClickListener() {
                    @Override
                    public void onClick(SweetAlertDialog sweetAlertDialog) {
                        sweetAlertDialog.dismiss();

                    }
                }, new SweetAlertDialog.OnSweetClickListener() {
                    @Override
                    public void onClick(SweetAlertDialog sweetAlertDialog) {
                        sweetAlertDialog.dismiss();
                        taskCancelOrder(false,(GBaseActivity) mContext,card.getOrderInfoBean().getOrder_id());
                    }
                });
            }
        });
        textViewPayMoneyRed.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(mContext, WebHtmlActivity.class);
                intent.putExtra(WebHtmlActivity.Title,"物流详情");
                intent.putExtra(WebHtmlActivity.WebUrl, Constant.getHtml5UrlFotParameter(Constant.HTML5.Html5_check_order_state,card.getOrderInfoBean().getExpress_type(),card.getOrderInfoBean().getExpress_number()));
                mContext.startActivity(intent);
            }
        });
    }
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    private void showViewDsh(final OrderListItemCard card) {
        imageViewFinish.setVisibility(View.GONE);
        imageViewDel.setVisibility(View.GONE);
        textViewWaitStatus.setVisibility(View.VISIBLE);
        textViewWaitStatus.setText("已发货");
        textViewWaitStatus.setTextColor(getResources().getColor(R.color.red));

        textViewPayMoneyRed.setVisibility(View.VISIBLE);
        textViewPayMoneyRed.setBackgroundResource(R.drawable.shape_radian_green);
        textViewPayMoneyRed.setText("查看物流");
        textViewBuyAgainGrey.setVisibility(View.VISIBLE);
        textViewBuyAgainGrey.setText("咨询药师");
/*        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.LEFT_OF);
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);*/
        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        layoutParams.addRule(RelativeLayout.LEFT_OF,R.id.textViewPayMoneyRed);
        showViewMoreGoods(card);
        textViewBuyAgainGrey.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ( (GBaseActivity)mContext).GoToChat();
            }
        });
        textViewPayMoneyRed.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(mContext, WebHtmlActivity.class);
                intent.putExtra(WebHtmlActivity.Title,"物流详情");
                intent.putExtra(WebHtmlActivity.WebUrl, Constant.getHtml5UrlFotParameter(Constant.HTML5.Html5_check_order_state,card.getOrderInfoBean().getExpress_type(),card.getOrderInfoBean().getExpress_number()));
                mContext.startActivity(intent);
            }
        });
    }
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    private void showViewDfh(final OrderListItemCard card) {
        imageViewFinish.setVisibility(View.GONE);
        imageViewDel.setVisibility(View.GONE);
        textViewWaitStatus.setVisibility(View.VISIBLE);
        textViewWaitStatus.setText("正在出货");
        textViewWaitStatus.setTextColor(getResources().getColor(R.color.red));
        textViewPayMoneyRed.setVisibility(View.GONE);
        textViewPayMoneyRed.setBackgroundResource(R.drawable.shape_radian_green);
        textViewPayMoneyRed.setText("查看物流");
        textViewBuyAgainGrey.setVisibility(View.VISIBLE);
        textViewBuyAgainGrey.setText("取消订单");
        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.LEFT_OF);
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        textViewBuyAgainGrey.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

                SweetDialogManager.getInstance().showDialogByWarmTitleText((GBaseActivity) mContext, "确认要取消订单吗?", "", false, false, new SweetAlertDialog.OnSweetClickListener() {
                    @Override
                    public void onClick(SweetAlertDialog sweetAlertDialog) {
                        sweetAlertDialog.dismiss();

                    }
                }, new SweetAlertDialog.OnSweetClickListener() {
                    @Override
                    public void onClick(SweetAlertDialog sweetAlertDialog) {
                        sweetAlertDialog.dismiss();
                        taskCancelOrder(false,(GBaseActivity) mContext,card.getOrderInfoBean().getOrder_id());
                    }
                });
            }
        });
        textViewPayMoneyRed.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(mContext, WebHtmlActivity.class);
                intent.putExtra(WebHtmlActivity.Title,"物流详情");
                intent.putExtra(WebHtmlActivity.WebUrl, Constant.getHtml5UrlFotParameter(Constant.HTML5.Html5_check_order_state,card.getOrderInfoBean().getExpress_type(),card.getOrderInfoBean().getExpress_number()));
                mContext.startActivity(intent);
            }
        });
        showViewMoreGoods(card);
    }
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    private void showViewDpj(OrderListItemCard card) {
        imageViewFinish.setVisibility(View.VISIBLE);
        imageViewDel.setVisibility(View.VISIBLE);
        textViewWaitStatus.setVisibility(View.GONE);
        textViewWaitStatus.setTextColor(getResources().getColor(R.color.red));
       // textViewWaitStatus.setText("等待付款");
        textViewPayMoneyRed.setVisibility(View.VISIBLE);
        textViewPayMoneyRed.setText("评价订单");
        textViewBuyAgainGrey.setVisibility(View.VISIBLE);
        textViewBuyAgainGrey.setText("再次购买");
        textViewPayMoneyRed.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(mContext, CheckOrderActivity.class);
                intent.putExtra(CheckOrderActivity.TagItemIDS,getCheckIDS());
                intent.putExtra(CheckOrderActivity.TagNumber,getCheckNumberS());
                intent.putExtra(CheckOrderActivity.TagType,CheckOrderActivity.TagTypeBugAgain);
                mContext.startActivity(intent);
            }
        });
        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        layoutParams.addRule(RelativeLayout.LEFT_OF,R.id.textViewPayMoneyRed);
        showViewMoreGoods(card);
    }
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    private void showViewYqx(OrderListItemCard card) {
        imageViewFinish.setVisibility(View.GONE);
        imageViewDel.setVisibility(View.GONE);
        textViewWaitStatus.setVisibility(View.VISIBLE);
        textViewWaitStatus.setTextColor(getResources().getColor(R.color.red));
        textViewWaitStatus.setText("交易关闭");
        textViewPayMoneyRed.setVisibility(View.VISIBLE);
        textViewPayMoneyRed.setBackgroundResource(R.drawable.shape_radian_green);
        textViewPayMoneyRed.setText("再次购买");
        textViewBuyAgainGrey.setVisibility(View.VISIBLE);
        textViewBuyAgainGrey.setText("咨询药师");
/*        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.LEFT_OF);
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);*/
        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        layoutParams.addRule(RelativeLayout.LEFT_OF,R.id.textViewPayMoneyRed);
        textViewBuyAgainGrey.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ( (GBaseActivity)mContext).GoToChat();
            }
        });
        textViewPayMoneyRed.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                textViewPayMoneyRed.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent =new Intent(mContext, CheckOrderActivity.class);
                        intent.putExtra(CheckOrderActivity.TagItemIDS,getCheckIDS());
                        intent.putExtra(CheckOrderActivity.TagNumber,getCheckNumberS());
                        intent.putExtra(CheckOrderActivity.TagType,CheckOrderActivity.TagTypeBugAgain);
                        mContext.startActivity(intent);
                    }
                });
            }
        });
        showViewMoreGoods(card);
    }
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    private void showViewYwc(OrderListItemCard card) {
        imageViewFinish.setVisibility(View.VISIBLE);
        imageViewDel.setVisibility(View.GONE);
        textViewWaitStatus.setVisibility(View.GONE);

        textViewPayMoneyRed.setVisibility(View.VISIBLE);
        textViewPayMoneyRed.setBackgroundResource(R.drawable.shape_radian_green);
        textViewPayMoneyRed.setText("再次购买");
        //   textViewPayMoneyRed.setText("去支付");
        textViewBuyAgainGrey.setVisibility(View.VISIBLE);
        textViewBuyAgainGrey.setText("咨询药师");

/*        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.LEFT_OF);
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);*/
        RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textViewBuyAgainGrey.getLayoutParams();
        layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        layoutParams.addRule(RelativeLayout.LEFT_OF,R.id.textViewPayMoneyRed);
        textViewBuyAgainGrey.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ( (GBaseActivity)mContext).GoToChat();
            }
        });
        textViewPayMoneyRed.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(mContext, CheckOrderActivity.class);
                intent.putExtra(CheckOrderActivity.TagItemIDS,getCheckIDS());
                intent.putExtra(CheckOrderActivity.TagNumber,getCheckNumberS());
                intent.putExtra(CheckOrderActivity.TagType,CheckOrderActivity.TagTypeBugAgain);
                mContext.startActivity(intent);
            }
        });
        showViewMoreGoods(card);
    }
    private String getCheckNumberS() {
        String numbers="";
        for (int i=0;i<orderListItemCard.getOrderInfoBean().getGoods().size();i++)
        {
            OrderInfoBean.GoodsEntity goodsEntity=orderListItemCard.getOrderInfoBean().getGoods().get(i);

            numbers+=goodsEntity.getNumber()+",";

        }
        if (!TextUtils.isEmpty(numbers)) {
            numbers = numbers.substring(0, numbers.length() - 1);
        }
        return numbers;
    }
    private String getCheckIDS() {
        String ids="";
        for (int i=0;i<orderListItemCard.getOrderInfoBean().getGoods().size();i++)
        {
            OrderInfoBean.GoodsEntity goodsEntity=orderListItemCard.getOrderInfoBean().getGoods().get(i);

                ids+=goodsEntity.getItemid()+",";

        }
        if (!TextUtils.isEmpty(ids)) {
            ids = ids.substring(0, ids.length() - 1);
        }
        return ids;
    }
    @Override
    public void onClick(View v) {
        Intent intent= new Intent(mContext, OrderDetailActivity.class);
        intent.putExtra(OrderDetailActivity.TagID,orderListItemCard.getOrderInfoBean().getOrder_id());
        mContext.startActivity(intent);
    }

    public static void taskCancelOrder(final boolean isloadmore,GBaseActivity gBaseActivity,String orderID) {
        RequestServerManager.getInstanceDIY().handleMethodDIY(gBaseActivity, null, isloadmore, null,
                Constant.getRootUrl() + Constant.Action.Action_OrderCancel, Constant.Action.Action_OrderCancel, RequestServerManager.getInstanceDIY().
                        getRequestParams(Constant.Action.Action_OrderCancel,App.getUserBean().getUserid(),App.getUserBean().getSession_id(),orderID), BaseResponse.class, new ICallBackForRequestServer<BaseResponse>() {
                    @Override
                    public void onSuccess(BaseResponse result) {
                        // JSONObject jsonObject = (JSONObject) result.getData();
                        EventBus.getDefault().post(new RefreshOrderListActivity());
                        ToastUtil.showToast("操作成功");
                    }

                    @Override
                    public void onFail(int type, String errorMsg, String json) {

                    }
                });
    }
}
